home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS01.ADF / C / Grep.doc < prev    next >
Text File  |  1985-12-04  |  3KB  |  79 lines

  1.  
  2.                         GREP
  3.                         ====
  4.  
  5. GREP searches a file for a given pattern.  Execute by:
  6.  
  7.    grep [flags] regular_expression file_list
  8.  
  9. Flags are single characters preceeded by '-':
  10.  
  11.    -c      Only a count of matching lines is printed
  12.    -f      Print file name for matching lines switch, see below
  13.    -n      Each line is preceeded by its line number
  14.    -v      Only print non-matching lines
  15.  
  16. The file_list is a list of files.
  17.  
  18. The file name is normally printed if there is a file given.
  19. The -f flag reverses this action (print name no file, not if more).
  20.  
  21. The regular_expression defines the pattern to search for.  Upper- and
  22. lower-case are always ignored.  Blank lines never match.  The expression
  23. should be quoted to prevent file-name translation.
  24.  
  25. x      An ordinary character (not mentioned below) matches that character.
  26. '\'    The backslash quotes any character.  "\$" matches a dollar-sign.
  27. '^'    A circumflex at the beginning of an expression matches the
  28.        beginning of a line.
  29. '$'    A dollar-sign at the end of an expression matches the end of a line.
  30. '.'    A period matches any character except "new-line".
  31. ':a'   A colon matches a class of characters described by the following
  32. ':d'     character.  ":a" matches any alphabetic, ":d" matches digits,
  33. ':n'     ":n" matches alphanumerics, ": " matches spaces, tabs, and
  34. ': '     other control characters, such as new-line.
  35. '*'    An expression followed by an asterisk matches zero or more
  36.        occurrances of that expression: "fo*" matches "f", "fo"
  37.        "foo", etc.
  38. '+'    An expression followed by a plus sign matches one or more
  39.        occurrances of that expression: "fo+" matches "fo", etc.
  40. '-'    An expression followed by a minus sign optionally matches
  41.        the expression.
  42. '[]'   A string enclosed in square brackets matches any character in
  43.        that string, but no others.  If the first character in the
  44.        string is a circumflex, the expression matches any character
  45.        except "new-line" and the characters in the string.  For
  46.        example, "[xyz]" matches "xx" and "zyx", while "[^xyz]"
  47.        matches "abc" but not "axb".  A range of characters may be
  48.        specified by two characters separated by "-".  Note that,
  49.        [a-z] matches alphabetics, while [z-a] never matches.
  50. The concatenation of regular expressions is a regular expression.
  51.  
  52. History:
  53.  
  54. Obtained from the CP/M SIG on CompuServe in 1983.  The program
  55. program contained this notice:
  56.  
  57.    The  information  in  this  document  is  subject  to  change
  58.    without  notice  and  should not be construed as a commitment
  59.    by Digital Equipment Corporation or by DECUS.
  60.  
  61.    Neither Digital Equipment Corporation, DECUS, nor the authors
  62.    assume any responsibility for the use or reliability of  this
  63.    document or the described software.
  64.  
  65.         Copyright (C) 1980, DECUS
  66.  
  67.    General permission to copy or modify, but not for profit,  is
  68.    hereby  granted,  provided that the above copyright notice is
  69.    included and reference made to  the  fact  that  reproduction
  70.    privileges were granted by DECUS.
  71.  
  72.    Runs on the Decus compiler or on vms.
  73.    Converted for BDS compiler (under CP/M-80), 20-Jan-83, by Chris Kern.
  74.  
  75. Converted to IBM PC with CI-C86 C Compiler June 1983 by David N. Smith.
  76. (CompuServe 73145,153. Address: 44 Ole Musket Lane, Danbury, CT 06810)
  77. Compiled using DeSmet in November 1983.  Converted to Lattice C for the
  78. Amiga, November 1985.
  79.